<template>

  <body id="poster">
    <div class="login_title">
      <span class="title">文档管理系统</span>
      <span class="subtitle">Document management system</span>
    </div>
    <el-form class="login-container"
             label-position="left"
             label-width="0px">
      <h3 class="login_title">系统登录</h3>
      <el-form-item>
        <el-input prefix-icon="el-icon-user"
                  type="text"
                  v-model.trim="loginForm.name"
                  auto-complete="off"
                  placeholder="账号">
        </el-input>
      </el-form-item>

      <el-form-item>
        <el-input prefix-icon="el-icon-lock"
                  :type="passw"
                  v-model.trim="loginForm.password"
                  auto-complete="off"
                  placeholder="密码">
          <i slot="suffix"
             :class="icon"
             @click="showPass">
          </i>
        </el-input>
      </el-form-item>

      <el-form-item style="width: 100%">
        <el-button type="primary"
                   style="width: 100%;background: #505458;border: none"
                   @click="login()"
                   v-on:keyup.enter="login()">
          <span>登录</span>
        </el-button>
      </el-form-item>
    </el-form>
  </body>
</template>

<script>

export default {
  name: "Login",
  data () {
    return {
      loginForm: {
        name: '',
        password: ''
      },
      responseResult: [],
      rules2: {
        name: [{ required: true, message: 'please enter your account', trigger: 'blur' }],
        password: [{ required: true, message: 'enter your password', trigger: 'blur' }]
      },
      checked: false,
      //用于改变Input类型
      passw: "password",
      //用于更换Input中的图标
      icon: "el-input-icon el-icon-view",
    }
  },
  methods: {
    login () {
      if (this.loginForm.name === '' || this.loginForm.password === '') {
        this.$alert('请输入用户名和密码!', '提示：', {
          confirmButtonText: 'ok'
        })
      } else if (this.loginForm.name !== '' && this.loginForm.password !== '') {
        console.log("调用接口进行登录")
      }
    },
    //密码的隐藏和显示
    showPass () {
      //点击图标是密码隐藏或显示
      if (this.passw === "text") {
        this.passw = "password";
        console.log(this.passw);
        //更换图标
        this.icon = "el-input-icon el-icon-view";
      } else {
        this.passw = "text";
        this.icon = "el-input-icon el-icon-loading";
      }
    }
  }
}
</script>
<style lang="less" scoped>
#poster {
  box-sizing: border-box;
  padding-top: 150px;
  background-image: url(../assets/img/bg.jpeg);
  background-position: center center;
  background-size: cover;
  background-attachment: fixed;
  height: 100%;
  width: 100%;
}

.login-container {
  border-radius: 15px;
  background-clip: padding-box;
  margin: 0 auto;
  width: 400px;
  height: 300px;
  padding: 35px 35px 15px 35px;
  background: #fff;
  border: 1px solid #eaeaea;
  box-shadow: 0 0 25px #cac6c6;
}

.login_title {
  margin: 0 auto 10px auto;
  text-align: center;
  color: #505458;
}

.title {
  display: block;
  color: #f1f1f1;
  font-size: 24px;
  letter-spacing: 2px;
  font-family: 黑体;
}

.subtitle {
  display: inline-block;
  margin: 5px 0 20px;
  color: lightgrey;
  font-size: 12px;
}
</style>
